/**
 * 响应摇杆事件的演示控件
 * 
 * Author   : jxyi
 * Date     : 2017-3-21
 */

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // use this for initialization
    onLoad: function () {
        this.stick = cc.find('joystick', this.node);
        this.avatar = cc.find('hero/spr_avatar', this.node);

        this.stick.on('joystick_move', this.handleJoystick, this);
    },

    handleJoystick: function(event) {
        var angle = event.getUserData().angle;
        this.avatar.rotation = angle * 180 / Math.PI;
    }
});
